

package com.maoshi.shop.groupbuy.platform.task;

import com.maoshi.shop.groupbuy.comment.model.GroupTeam;
import com.maoshi.shop.groupbuy.comment.service.GroupTeamService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 拼团任务定时任务
 *
 * @author 小懒虫
 * @date 2019/9/3 11:41
 */
@Component("groupBuyTask")
public class GroupBuyTask {

    private Logger logger = LoggerFactory.getLogger(getClass());

    @Autowired
    private GroupTeamService groupTeamService;



    /**
     * 拼团活动/团订单结束任务
     */
    public void activityFinish() {
        logger.info("取消拼团活动/团订单结束的任务。。。");
        // 获取活动结束或团单结束未成团的拼团团队
        List<GroupTeam> groupTeams = groupTeamService.getNotGroupTeam();
        if (groupTeams.size() > 0) {
            // 处理未成团的拼团团队，返回退款单列表
            for (GroupTeam groupTeam : groupTeams) {
                groupTeamService.updateNotGroupTeam(groupTeam);
            }
        }
    }
}
